import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AgentCdVO, AgentCdForm, AgentCdQuery } from '@/api/business/agentCd/types';

/**
 * 查询城代管理列表
 * @param query
 * @returns {*}
 */

export const listAgentCd = (query?: AgentCdQuery): AxiosPromise<AgentCdVO[]> => {
  return request({
    url: '/business/agentCd/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询城代管理详细
 * @param id
 */
export const getAgentCd = (id: string | number): AxiosPromise<AgentCdVO> => {
  return request({
    url: '/business/agentCd/' + id,
    method: 'get'
  });
};

/**
 * 新增城代管理
 * @param data
 */
export const addAgentCd = (data: AgentCdForm) => {
  return request({
    url: '/business/agentCd',
    method: 'post',
    data: data
  });
};

/**
 * 修改城代管理
 * @param data
 */
export const updateAgentCd = (data: AgentCdForm) => {
  return request({
    url: '/business/agentCd',
    method: 'put',
    data: data
  });
};

/**
 * 删除城代管理
 * @param id
 */
export const delAgentCd = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/agentCd/' + id,
    method: 'delete'
  });
};

/**
 * 用户密码重置
 * @param userId 用户ID
 * @param password 密码
 */
export const resetUserPwd = (userId: string | number, password: string) => {
  const data = {
    userId,
    password
  };
  return request({
    url: '/business/agentCd/resetPwd',
    method: 'put',
    headers: {
      isEncrypt: true,
      repeatSubmit: false
    },
    data: data
  });
};
